<template>
	<view class="content">
		<!-- <view class="list-item policy-item" v-for="item in policyList" :key="item.id"
				@click="menuJump(item.url,item.id)">
				<view class="img">
				<image v-if="item.cover" :src="item.cover" alt="" class="play">
					<image mode="aspectFill" v-else
						src="https://jinchang-job-1306862033.cos.ap-chengdu.myqcloud.com/miniprogram-static/job_hunting/index/5QOYcaFv.png"
						class="play"></image>
					</view>
					<view class="policy-info">
						<view class="title">
							{{ item.title }}
						</view>
						<view class="time">
							{{ item.createTime }}
						</view>
					</view>
			</view> -->
		<view class="block list-block">
			<template v-if="policyList.length>0">
				<view @click="navigate('/page_other/disseminate/detail?id='+item.id+'&type=1')"
					class="list-item policy-item" v-for="(item,index) in policyList" :key="item.id">
					<image mode="aspectFill" :src="item.cover" class="cover-photo" v-if="item.cover"></image>
					<image mode="aspectFill" v-else
						src="https://jinchang-job-1306862033.cos.ap-chengdu.myqcloud.com/miniprogram-static/job_hunting/index/5QOYcaFv.png"
						class="cover-photo"></image>
					<view class="info">
						<view class="title overflow-line">{{item.title}}</view>
						<view class="time">发布时间：{{item.createTime}}</view>
					</view>
				</view>
			</template>
			<view class="empty" v-else>暂无数据</view>
		</view>

	</view>
</template>

<script>
	import {
		isMore
	} from '@/util/util.js'
	import {
		getPromotionList,
		getPromotioList
	} from '@/api/disseminate.js'
	export default {
		data() {
			return {
				config: {
					page: 1,
					limit: 10,
					total: 0,
				},
				more: true,
				policyList: [],
				// 	policyList: [{
				// 			id: 1,
				// 			src: "/home/chuangye/tupian1.png",
				// 			title: "酒泉舒心水果业商贸有限公司  总经理  董事长  白玉恒",
				// 			time: "2023-03-04",
				// 			url: '/page_other/serve/case_detail'
				// 		},
				// 		{
				// 			id: 2,
				// 			src: '/home/chuangye/tupian2.png',
				// 			title: "酒泉诚德农业农民专业合作社  理事长   范立德",
				// 			time: "2023-03-04",
				// 			url: '/page_other/serve/case_detail1'
				// 		},
				// 		{
				// 			id: 3,
				// 			src: "/home/chuangye/tupian3.png",
				// 			title: "甘肃雄狮保安服务有限公司  董事长  韩进彪",
				// 			time: "2023-03-04",
				// 			url: '/page_other/serve/case_detail2'
				// 		},
				// 		{
				// 			id: 4,
				// 			src: "/home/chuangye/tupian4.png",
				// 			title: "甘肃吉光片羽时代文化传媒有限公司 总经理 祁博",
				// 			time: "2023-03-04",
				// 			url: '/page_other/serve/case_detail3'
				// 		},
				// 		{
				// 			id: 5,
				// 			src: "/home/chuangye/tupian5.png",
				// 			title: "甘肃渤汇恒达工程检测有限公司 总经理  于松平",
				// 			time: "2023-03-04",
				// 			url: '/page_other/serve/case_detail4'
				// 		},
				// 		{
				// 			id: 6,
				// 			src: "/home/chuangye/tupian6.png",
				// 			title: "酒泉盛天农业发展有限公司  董事长  盛晓玲",
				// 			time: "2023-03-04",
				// 			url: '/page_other/serve/case_detail5'
				// 		},
				// 		{
				// 			id: 7,
				// 			src: "/home/chuangye/tupian7.png",
				// 			title: "甘肃非凡洁净日化有限公司  董事长  王建明",
				// 			time: "2023-03-04",
				// 			url: '/page_other/serve/case_detail6'
				// 		}
				// 	]


			}
		},
		methods: {
			navigate(url) {
				uni.navigateTo({
					url
				})
			},
			refresh() {
				this.config.page = 1
				this.more = true


				this.getList(true)


			},
			async getList(refresh = false) {
				if (this.more) {
					uni.showLoading({
						title: '加载中',
						mask: true
					})
					let res = await getPromotionList(this.config)
					let list = res.list ?? [];
					this.policyList = refresh ? list : [...this.policyList, ...list],
						this.config.total = res.count
					this.more = isMore(this.config.page, this.config.limit, this.config.total)
				}
			},
			menuJump(url, id) {
				if (url) {
					uni.navigateTo({
						url: url + '?id=' + id
					})
				} else {
					uni.showToast({
						title: '该功能正在研发中QWQ~',
						icon: 'none'
					})
				}
			},
			onReachBottom() {
				if (this.more) {
					this.config.page++;

					this.getList()
				}
			},
		},
		onLoad(e) {
			this.getList()
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		padding: 30rpx;

		.article-tab {
			width: 100%;
			height: 70rpx;
			display: flex;
			flex-direction: row;
			align-items: center;
			font-weight: bold;
			font-size: 34rpx;
			color: #313131;

			.tab-item {
				margin-right: 30rpx;
				display: flex;
				align-items: center;
				justify-content: center;
			}

			.tab-item.active {
				color: #0256FF;
				height: 100%;
			}
		}

		.list-block.block {
			margin-top: 30rpx;
			width: 100%;
			display: flex;
			flex-direction: column;

			.list-item.policy-item {
				height: 220rpx;
				width: 100%;
				padding: 30rpx 0;
				display: flex;
				flex-direction: row;
				border-radius: 20rpx;
				background: #fff;
				margin-bottom: 30rpx;
				padding: 20rpx;
				box-shadow: 0 0 10px 0 #efefef;

				.cover-photo {
					width: 180rpx;
					height: 180rpx;
					border-radius: 10rpx;
					margin-right: 20rpx;
					background: #efefef;
				}

				.info {
					width: calc(100% - 200rpx);
					height: 100%;

					.title {
						font-weight: bold;
					}

					.abstract {
						font-size: 24rpx;
						color: #999;
						display: -webkit-box;
						-webkit-box-orient: vertical;
						-webkit-line-clamp: 2;
						overflow: hidden;
						margin-top: 10rpx;
						line-height: 1.5;
					}

					.time {
						margin-top: 10rpx;
						font-size: 28rpx;
						color: #999;
					}
				}
			}

		}
	}
</style>